home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / recode.lha / recode-3.2.4 / banglat1.c < prev    next >
C/C++ Source or Header  |  1992-08-19  |  4KB  |  145 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1990 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1988.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. #define STEP    bangbang_latin1
  21. #include <stdio.h>
  22. #include "common.h"
  23.  
  24. /* Previous obsolete lex code:
  25.  
  26. [A-Z]            { output (yytext[0]-'A'+'a'); }
  27.  
  28. !\"            { output ('!'); }
  29.  
  30. !0            { output ('\340'); /+ a` +/ }
  31. !1            { output ('\342'); /+ a^ +/ }
  32. !2            { output ('\351'); /+ e' +/ }
  33. !3            { output ('\350'); /+ e` +/ }
  34. !4            { output ('\353'); /+ e" +/ }
  35. !5            { output ('\352'); /+ e^ +/ }
  36. !6            { output ('\354'); /+ e" +/ }
  37. !7            { output ('\356'); /+ i^ +/ }
  38. !8            { output ('\364'); /+ o^ +/ }
  39. !9            { output ('\371'); /+ u` +/ }
  40. !:            { output ('\373'); /+ u^ +/ }
  41.  
  42. !=            { output ('\347'); /+ c, +/ }
  43. !>            { output ('\253'); /+ `` +/ }
  44. !\?            { output ('\273'); /+ '' +/ }
  45.  
  46. !@            { output ('`'); }
  47.  
  48. ![A-Z]            { output (yytext[1]); }
  49.  
  50. !\[            { output ('{'); }
  51. !\\            { output ('|'); }
  52. !]            { output ('}'); }
  53. !^            { output ('~'); }
  54.  
  55. !_            { output ('\177'); }
  56.  
  57. ![a-z]            { output (yytext[1]-'a'+'A'); }
  58.  
  59. !!@            { output ('\000'); }
  60.  
  61. !![A-Z]            { output (yytext[2]-'A'+1); }
  62.  
  63. !!\[            { output ('\033'); }
  64. !!\\            { output ('\034'); }
  65. !!]            { output ('\035'); }
  66. !!^            { output ('\036'); }
  67. !!_            { output ('\037'); }
  68.  
  69. !![a-z]            { output (yytext[2]-'a'+1); }
  70.  
  71. */
  72.  
  73. void
  74. STEP (FILE *input_file, FILE *output_file)
  75. {
  76.   int input_char;        /* current character */
  77.  
  78.   while ((input_char = getc (input_file)) != EOF)
  79.     {
  80.       if (input_char >= 'A' && input_char <= 'Z')
  81.         input_char += 'a' - 'A';
  82.       else if (input_char == '!')
  83.     {
  84.       input_char = getc (input_file);
  85.       if (input_char >= 'a' && input_char <= 'z')
  86.         input_char += 'A' - 'a';
  87.       else if (input_char < 'A' || input_char > 'Z')
  88.         switch (input_char)
  89.           {
  90.           case '"': input_char = '!'; break;
  91.           case '0': input_char = '\340'; break; /* a` */
  92.           case '1': input_char = '\342'; break; /* a^ */
  93.           case '2': input_char = '\351'; break; /* e' */
  94.           case '3': input_char = '\350'; break; /* e` */
  95.           case '4': input_char = '\353'; break; /* e" */
  96.           case '5': input_char = '\352'; break; /* e^ */
  97.           case '6': input_char = '\354'; break; /* e" */
  98.           case '7': input_char = '\356'; break; /* i^ */
  99.           case '8': input_char = '\364'; break; /* o^ */
  100.           case '9': input_char = '\371'; break; /* u` */
  101.           case ':': input_char = '\373'; break; /* u^ */
  102.           case '=': input_char = '\347'; break; /* c, */
  103.           case '>': input_char = '\253'; break; /* `` */
  104.           case '?': input_char = '\273'; break; /* '' */
  105.           case '@': input_char = '`'; break;
  106.           case '[': input_char = '{'; break;
  107.           case '\\': input_char = '|'; break;
  108.           case ']': input_char = '}'; break;
  109.           case '^': input_char = '~'; break;
  110.           case '_': input_char = '\177'; break; /* del */
  111.  
  112.           case '!':
  113.             input_char = getc (input_file);
  114.         if (input_char >= 'A' && input_char <= 'Z')
  115.           input_char += 1 - 'A';
  116.             else if (input_char >= 'a' && input_char <= 'z')
  117.           input_char += 1 - 'a';
  118.             else
  119.           switch (input_char)
  120.             {
  121.             case '@': input_char = '\000'; break;
  122.             case '[': input_char = '\033'; break;
  123.             case '\\': input_char = '\034'; break;
  124.             case ']': input_char = '\035'; break;
  125.             case '^': input_char = '\036'; break;
  126.             case '_': input_char = '\037'; break;
  127.  
  128.             default:
  129.               putc ('!', output_file);
  130.               putc ('!', output_file);
  131.               if (input_char == EOF)
  132.                 return;
  133.             }
  134.         break;
  135.  
  136.           default:
  137.             putc ('!', output_file);
  138.             if (input_char == EOF)
  139.           return;
  140.           }
  141.     }
  142.       putc (input_char, output_file);
  143.     }
  144. }
  145.